package com.googlecode.ozonbooksfinder.cairngormfinder.command
{
	import com.adobe.cairngorm.commands.ICommand;
	import com.adobe.cairngorm.control.CairngormEvent;
	import com.googlecode.ozonbooksfinder.cairngormfinder.event.ShowViewEvent;
	import com.googlecode.ozonbooksfinder.cairngormfinder.model.CairngormFinderModelLocator;
	
	public class ShowViewCommand implements ICommand
	{
		private var model:CairngormFinderModelLocator = CairngormFinderModelLocator.getInstance();
		
		public function execute(event:CairngormEvent):void
		{
			switch (ShowViewEvent(event).view)
			{
				case CairngormFinderModelLocator.VIEW_MAIN_BOOK_LIST:
				{
					model.mainViewState = CairngormFinderModelLocator.VIEW_STATE_MAIN_BOOK_LIST;
					break;
				}
				case CairngormFinderModelLocator.VIEW_MAIN_BOOK_LIST_SEARCH:
				{
					model.mainViewState = CairngormFinderModelLocator.VIEW_STATE_MAIN_BOOK_LIST;
					model.searchMode = true;
					break;
				}
				case CairngormFinderModelLocator.VIEW_MAIN_BOOK_LIST_FAVORITES:
				{
					model.mainViewState = CairngormFinderModelLocator.VIEW_STATE_MAIN_BOOK_LIST;
					model.searchMode = false;
					break;
				}
			}
		}

	}
}